/**
 * 
 */
package constrain;

/**
 * @author Kyniek
 *
 */
public enum ConstraintType
{	
	NOT_NULL
	{
		public String generateCode(String... args)
		{
			return " NOT NULL";
		}
	}, UNIQUE
	{
		public String generateCode(String... args)
		{
			return " UNIQUE";
		}
	}	
	,  PRIMARY_KEY
	{
		public String generateCode(String... args)
		{
			String res = " PRIMARY KEY";
			
			if(args != null && args.length != 0)
			{
				if(args[0] != null)
				{
					res += " " + args[0];
					if(args.length >= 2)
					{
						res += " " + args[1];
					}
				}
			}
			
			return res;
		}
	},FOREIGN_KEY
	{
		public String generateCode(String... args)
		{
			String res = " REFERENCES " + args[0] + "(" + args[1] + ")" ;			
			return res;
		}
	}	
	, CHECK
	{
		public String generateCode(String... args)
		{
			String res = " CHECK " + "(" + args[0] + ")" ;			
			return res;
		}
	}	
	, DEFAULT;
	
	private String code;
	
//	Constrain()
//	{
//		;
//	};
//	
//	String[] params;
	
	public String generateCode(String... args)
	{
		return " DEFAULT " + args[0];
	}
	
	public void setParams(String... args)
	{
		code = generateCode(args);
	}
	
	public String getCode()
	{
		if(code != null)
			return code;
		else
			return "";
	}

}



